package top.wuchu.test;

import top.wuchu.rpc.api.ByeService;
import top.wuchu.rpc.api.HelloObject;
import top.wuchu.rpc.api.HelloService;
import top.wuchu.rpc.serializer.CommonSerializer;
import top.wuchu.rpc.transport.RpcClient;
import top.wuchu.rpc.transport.RpcClientProxy;
import top.wuchu.rpc.transport.netty.client.NettyClient;

/**
 * 测试用Netty消费者
 *
 * @author Wuchu
 */
public class NettyTestClient {

    public static void main(String[] args) {

        RpcClient client = new NettyClient(CommonSerializer.PROTOBUF_SERIALIZER);
        RpcClientProxy proxy = new RpcClientProxy(client);

        // 这个helloService相当于是代理对象，它专门负责去调用HelloService接口里面的方法
        HelloService helloService = proxy.getProxy(HelloService.class);
        // 参数
        HelloObject object = new HelloObject(12, "This is a message");
        // 代理对象去调用HelloService接口里面的hello方法
        String res = helloService.hello(object);
        System.out.println(res);

        // 这个byeService相当于是代理对象，它专门负责去调用ByeService接口里面的方法
        ByeService byeService = proxy.getProxy(ByeService.class);
        System.out.println(byeService.bye("Netty"));
    }

}
